<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/wx/page/session.jsp"%>
<c:set var="userId" value="${param.userId}" />
<c:set var="deptId" value="${param.deptId}" />
<c:set var="deptCode" value="${param.deptCode}" />
<c:set var="deptParentId" value="${param.deptParentId}" />
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <title>通讯录</title>
    <link rel="stylesheet" href="${ctx}/wx/css/default.css"/>
    <link rel="stylesheet" href="${ctx}/wx/css/xtable.css"/>
    <script type="text/javascript" src="${ctx}/wx/js/xtable.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/util.js"></script>
    <script type="text/javascript" src="${ctx}/wx/js/alert.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/interface/UserService.js"></script>
</head>
<body>
<p class="contact-input">
    <select id="userType" name="userType" onchange="getUserPage()">
        <option value="1">员工</option>
        <option value="2">货主</option>
        <option value="3">司机</option>
    </select>
</p>

<SCRIPT LANGUAGE="JavaScript" type="">
    var userThead = new Array(
//            new XThead("照片"),
            new XThead("姓名"),
            new XThead("类型"),
            new XThead("电话")
    );

    var userXTable = new XTable("user", userThead);

    userXTable.XTbodyArray = function (model) {
        var array = new Array(
                new XTbody("user", model.userName, null, null, null, "center"),
                new XTbody("user", model.userType == 1 ? "员工" : model.userType == 2 ? "货主" : model.userType == 3 ? "司机" : "", null, null, null, "center"),
                new XTbody("user", "<a href='tel:" + model.userMobile + "'>" + model.userMobile + "</a>", null, null, null, "center")
        );
        return array;
    }
    userXTable.getXList = function (page){
        var user = new User();
        user.userType = dwr.util.getValue("userType");
        var deptUser = new DeptUser();
        deptUser.user = user;
        if(user.userType == 1){
            deptUser.deptId = "${deptId}";
        } else {
            deptUser.deptParentId = "${deptParentId}";
        }
        user.pageIndex = page;
        user.pageSize = userXTable.pageSize;
        UserService.selectUserList(deptUser, function(list){userXTable.addTable(list);});
    }
    function getUserPage(){
        var user = new User();
        user.userType = dwr.util.getValue("userType");
        var deptUser = new DeptUser();
        deptUser.user = user;
        if(user.userType == 1){
            deptUser.deptId = "${deptId}";
        } else {
            deptUser.deptParentId = "${deptParentId}";
        }
        UserService.selectUserNum(deptUser, function(num){userXTable.setTotalPage(num);});
    }
</SCRIPT>
</body>
</html>
<script type="text/javascript">
    getUserPage();
</script>